<template>
  <el-dialog
    title="选择维护标准"
    :close-on-click-modal="false"
    :visible.sync="visible"
    class="JNPF-dialog JNPF-dialog_center"
    lock-scroll
    append-to-body
    width="900px"
  >
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent>
        <el-col :span="10">
          <el-form-item label="关键词">
            <el-input
              v-model="keyword"
              placeholder="请输入关键词查询"
              clearable
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="init()"
              >{{ $t("common.search") }}
            </el-button>
            <el-button icon="el-icon-refresh-right" @click="refresh()"
              >{{ $t("common.reset") }}
            </el-button>
          </el-form-item>
        </el-col>
      </el-form>
      <div class="JNPF-common-search-box-right">
        <el-tooltip
          effect="dark"
          :content="$t('common.refresh')"
          placement="top"
        >
          <el-link
            icon="icon-ym icon-ym-Refresh JNPF-common-head-icon"
            :underline="false"
            @click="refresh()"
          />
        </el-tooltip>
      </div>
    </el-row>
    <JNPF-table
      v-loading="listLoading"
      :data="list"
      hasC
      @selection-change="handleSelectionChange"
      :border="false"
    >
      <el-table-column prop="name" label="名称"  />
      <el-table-column label="检修/维护"  prop="flag" algin="left">
		<template slot-scope="scope">{{ scope.row.flag | dynamicText(flagOptions) }}</template>
	 </el-table-column>
      <el-table-column prop="times" label="次数" />
      <el-table-column label="周期类型"  prop="cycletype" algin="left">
		<template slot-scope="scope">{{ scope.row.cycletype | dynamicText(cycletypeOptions) }}</template>
		</el-table-column>
      <el-table-column prop="person" label="创建人员" />
      <el-table-column prop="adddate" label="创建时间" width="120" />
    </JNPF-table>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">{{
        $t("common.cancelButton")
      }}</el-button>
      <el-button type="primary" @click="select()">{{
        $t("common.confirmButton")
      }}</el-button>
    </span>
  </el-dialog>
</template>

<script>
import request from '@/utils/request'
import { GoodsList } from "@/api/extend/order";
export default {
  data() {
    return {
      visible: false,
      listLoading: true,
      keyword: "",
      list: [],
      total: 0,
      checked: [],
      query: { name: undefined, flag: 1 },
      query2: { flag: 1 },
      listQuery: {
        currentPage: 1,
        pageSize: 20,
        flag: 2,
        sort: "desc",
        sidx: "",
      },
      flagOptions:[{"fullName":"维护","id":"1"}],
	  cycletypeOptions:[{"fullName":"日","id":"1"},{"fullName":"周","id":"2"},{"fullName":"月","id":"3"},{"fullName":"年","id":"4"}],
    };
  },
  methods: {
    init() {
      this.visible = true;
      this.listLoading = true;
      let query = {
                    ...this.listQuery,
                    ...this.query,
                    ...this.query2,
                    name: this.keyword
                };

        request({
                    url: `/api/System/DEVICETYPE`,
                    method: 'get',
                    data: query
                }).then(res => {
                    this.list = res.data.list;
                    this.listLoading = false;

                })        

    //   GoodsList(query).then((res) => {
    //     this.list = res.data.list;
    //     this.listLoading = false;
    //   });
    },
    refresh() {
      this.keyword = "";
      this.init();
    },
    select() {
      if (!this.checked.length) return;
      this.visible = false;
      this.$emit("refreshDataList_w", this.checked);
    },
    handleSelectionChange(val) {
      this.checked = val;
    },
  },
};
</script>
<style lang="scss" scoped>
>>> .el-dialog__body {
  height: 70vh;
  padding: 0 0 10px !important;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .JNPF-common-search-box {
    margin-bottom: 0;
    .JNPF-common-search-box-right {
      padding: 10px 10px 0 0;
    }
  }
}
</style>